import request from '@/utils/request'

/**
 * 获取公司所有角色列表
 * @param {*} page
 * @param {*} pagesize
 * @returns
 */
export const reqGetRoleList = (page, pagesize) => {
  return request({
    url: '/sys/role',
    method: 'get',
    params: {
      page,
      pagesize
    }
  })
}

/**
 *添加功能
 * @param {*} data 两个参数 name和description
 * @returns
 */
export const reqAddRole = (data) => {
  return request({
    url: '/sys/role',
    method: 'post',
    data
  })
}

/**
 * 删除角色
 * @param {*} id
 * @returns
 */
export const reqDeleteRole = (id) => {
  return request({
    url: `/sys/role/${id}`,
    method: 'DELETE'
  })
}

/**
 * 获取角色详情
 * @param {} id
 * @returns
 */
export const reqDetailRole = (id) => {
  return request({
    url: `/sys/role/${id}`,
    method: 'get'
  })
}

/**
 * 编辑更新角色
 * @param {*} id
 * @returns
 */
export const reqEditRole = (data) => {
  return request({
    url: `/sys/role/${data.id}`,
    method: 'put',
    data
  })
}

export const reqAssignPerm = (data) => {
  return request({
    url: '/sys/role/assignPrem',
    method: 'put',
    data
  })
}
